package day07;


import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.FileInputStream;
import java.io.IOException;
import java.sql.Connection;
import java.util.Properties;

public class TestDemo1 {
    public static void main(String[] args) throws Exception {
        //使用Properties和字节流读取项目目录下的配置文件
        Properties ps=new Properties();
        FileInputStream fs=new FileInputStream("druid.properties");
        ps.load(fs);
        //获得连接池对象
        DataSource dataSource = DruidDataSourceFactory.createDataSource(ps);
        for (int i = 1; i <=10 ; i++) {
            //根=根据连接池对象来获取连接对象
            Connection conn = dataSource.getConnection();
            System.out.println("第"+i+"个Connection对象"+conn);
        }
    }
}
